<template>
	<view class="comment">
		<view class="text-center">
			<input class="input-text"  v-model="facility.facility" placeholder="请输入设备序列号"></input>
			<input class="input-text" v-model="facility.pwd" placeholder="请输入验证码"> </input>
			<u-button class="button" @click="addfa">确认添加</u-button>
		</view>
		
	</view>
</template>

<script>
	import {
		addFacility
	} from "@/nxTemp/apis/facility.js"
	
	let userId = uni.getStorageSync("userId") || 0;
	export default {
		data() {
			return {
				facility: {
					facility: '',
					isOnline: 0,
					facilityType: 0,
					userId: userId,
					bindingTime: new Date(),
					createdTime: new Date(),
					pwd: ''
				}
			}
		},
		methods: {
			
			addfa:function(ars){
				let that = this;
				if (this.facility.facility.length < 7) {
					uni.showToast({
						icon: 'none',
						title: '设备序列号不正确！'
					});
					return;
				}
				if (this.facility.pwd.length < 6) {
					uni.showToast({ 
						icon: 'none',
						title: '密码不正确'
					});
					return;
				}
				addFacility(this.facility).then(res=>{
					console.log(res.data)
				})
			}
		}
	}
</script>

<style>
	.input-text{
		line-height: 40rpx;
		margin-top: 100rpx;
	}
	.button{
	
		background: #00aa00;
		margin-top: 100rpx;
		color: #fff;
		border: 0;
		border-radius: 100rpx;
		font-size: 36rpx;
	}

</style>
